__author__ = 'Janos G. Hajagos'

from ObjGraphicFile import *

class MaterialProperty(object):
    material_attribute = None

class Color(MaterialProperty):
    material_attribute = "Color"

class ColorRGB(Color):
    """Creates a color object"""
    def __init__(self, red=0.0, green=0.0, blue=0.0):
        self.red = red
        self.green = green
        self.blue = blue

class Red(Color):
    def __init__(self):
        self.blue = 0.0
        self.red = 0.8
        self.green = 0.0

class Blue(Color):
    def __init__(self):
        self.green = 0.0
        self.blue = 0.8
        self.red = 0.0

class Green(Color):
    def __init__(self):
        self.green = 1.0
        self.blue = 0.0
        self.red = 0.0

class MiddleGrey(Color):
    def __init__(selfs):
        self.green = 0.5
        self.blue = 0.5
        self.red = 0.5

class Diffuse(MaterialProperty):
    material_attribute = "Diffuse"
    def __init__(self,color = None, image_map=None):
        self.color = color
        self.image_map = image_map

class Glossy(MaterialProperty):
    material_attribute = "Glossy"
    def __init__(self, color = None):
        self.color = color

class ImageMap(MaterialProperty):
    material_attribute = "ImageMap"
    def __init__(self,image_name):
        self.image_name = image_name

class Material(object):

    def __init__(self,name,*list_of_material_definitions):
        self.mtl_material_obj = MtlMaterial(name)
        for material_def in list_of_material_definitions:
            if material_def.material_attribute == "Diffuse":
                if material_def.color:
                    self.mtl_material_obj.diffuse_color = (material_def.color.red,material_def.color.green,material_def.color.blue)
                if material_def.image_map:
                    self.mtl_material_obj.map_diffuse = material_def.image_map.image_name
            elif material_def.material_attribute == "Glossy":
                if material_def.color:
                    self.mtl_material_obj.specular_color = (material_def.color.red,material_def.color.green,material_def.color.blue)
    def name(self):
        return self.mtl_material_obj.name

class NamedMaterial(Material):
    def  __init__(self,name):
        self.material_name = name
    def name(self):
        return self.material_name
